'\" te
.\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH PLOCK 3C "Mar 22, 2004"
.SH NAME
plock \- lock or unlock into memory process, text, or data
.SH SYNOPSIS
.LP
.nf
#include <sys/lock.h>

\fBint\fR \fBplock\fR(\fBint\fR \fIop\fR);
.fi

.SH DESCRIPTION
.sp
.LP
The \fBplock()\fR function allows the calling process to lock or unlock into
memory its text segment (text lock), its data segment (data lock), or both its
text and data segments (process lock). Locked segments are immune to all
routine swapping. The effective user ID of the calling process must be
super-user to use this call.
.sp
.LP
The \fBplock()\fR function performs the function specified by \fIop\fR:
.sp
.ne 2
.na
\fB\fBPROCLOCK\fR\fR
.ad
.RS 12n
Lock text and data segments into memory (process lock).
.RE

.sp
.ne 2
.na
\fB\fBTXTLOCK\fR\fR
.ad
.RS 12n
Lock text segment into memory (text lock).
.RE

.sp
.ne 2
.na
\fB\fBDATLOCK\fR\fR
.ad
.RS 12n
Lock data segment into memory (data lock).
.RE

.sp
.ne 2
.na
\fB\fBUNLOCK\fR\fR
.ad
.RS 12n
Remove locks.
.RE

.SH RETURN VALUES
.sp
.LP
Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
returned and \fBerrno\fR is set to indicate the error.
.SH ERRORS
.sp
.LP
The \fBplock()\fR function fails and does not perform the requested operation
if:
.sp
.ne 2
.na
\fB\fBEAGAIN\fR\fR
.ad
.RS 10n
Not enough memory.
.RE

.sp
.ne 2
.na
\fB\fBEINVAL\fR\fR
.ad
.RS 10n
The \fIop\fR argument is equal to \fBPROCLOCK\fR and a process lock, a text
lock, or a data lock already exists on the calling process; the \fIop\fR
argument is equal to \fBTXTLOCK\fR and a text lock or a process lock already
exists on the calling process; the \fIop\fR argument is equal to \fBDATLOCK\fR
and a data lock or a process lock already exists on the calling process; or the
\fIop\fR argument is equal to \fBUNLOCK\fR and no lock exists on the calling
process.
.RE

.sp
.ne 2
.na
\fB\fBEPERM\fR\fR
.ad
.RS 10n
The {\fBPRIV_PROC_LOCK_MEMORY\fR} privilege is not asserted in the effective
set of the calling process.
.RE

.SH USAGE
.sp
.LP
The \fBmlock\fR(3C) and \fBmlockall\fR(3C) functions are the preferred
interfaces for process locking.
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	MT-Safe
.TE

.SH SEE ALSO
.sp
.LP
.BR exec (2),
.BR exit (2),
.BR fork (2),
.BR memcntl (2),
.BR mlock (3C),
.BR mlockall (3C),
.BR attributes (7)
